<template>
<el-dialog title="学生列表" :visible.sync="dialogTableVisible">
  <el-table :data="dataList">
    <el-table-column property="createTime" label="日期" width="150"></el-table-column>
    <el-table-column property="userName" label="姓名" width="100"></el-table-column>
    <el-table-column property="courseName" label="任务名称" width="200"></el-table-column>
    <el-table-column property="teacherName" label="教师名称"></el-table-column>
    <el-table-column property="courseAddress" label="上课地点"></el-table-column>
    <el-table-column property="courseDate" label="上课时间"></el-table-column>
  </el-table>
  <el-pagination @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
  </el-pagination>
</el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        dataList: [],
        dialogTableVisible: false,
        dialogFormVisible: false,
        form: {
          name: '',
          region: '',
          date1: '',
          date2: '',
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        },
        formLabelWidth: '120px',
        options: [],
        selectedOptions: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        courseId: ''
      }
    },
    methods: {
      init (id, disabled) {
        this.dialogTableVisible = disabled
        this.courseId = id
        this.getDataList(id)
      },
      getDataList (id) {
        this.$http({
          url: '/sys/jmcourseuser/list2',
          method: 'get',
          params: {
            page: this.pageIndex,
            limit: this.pageSize,
            courseId: id,
            flag: '2'
          }
        }).then(({data}) => {
          this.dataList = data.page.records
          this.totalPage = data.page.total
        })
      },
      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
      },
     // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        console.log('val=' + val)
        this.getDataList(this.courseId)
      }
    }
  }
</script>